<%@ page import="br.com.unip.modelo.Departamento,br.com.unip.persistencia.DepartamentoDao"%>
<%@ page import="br.com.unip.modelo.Funcionario,br.com.unip.persistencia.FuncionarioDao"%>
<%@ page import="java.util.List"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Departamento - Atualizar</title>
</head>
<%
try{
	Integer id = Integer.parseInt(request.getParameter("id"));
	
	DepartamentoDao dd1 = new DepartamentoDao();
	Departamento d = dd1.buscarPorId(id);
%>
<h2>Departamento - Atualizar</h2>
<form action="controle.jsp?action=atualizar&id=<%=d.getNro_dpto() %>" method="post">
	<label for="nome">Nome</label><br /> 
		<input type="text" name="nome" value="<%= d.getNome() %>" /><br />
		<label for="cod_ger">Gerente</label><br /> 
		<select name="cod_ger">
			<%
				try {
					FuncionarioDao fd = new FuncionarioDao();
					List<Funcionario> listar = fd.listar();

					for (Funcionario rp : listar) {
			%>
			<option value="<%=rp.getCod_func()%>" <% if (d.getCod_ger() == rp.getCod_func()) { out.print("selected='selected'"); } %>><%=rp.getNome()%></option>
			<%
				}
				} catch (Exception e) {
					out.print("Erro" + e);
				}
			%>
		</select><br /><br /> 
	<input type="submit" value="Atualizar" /> ou <a href="index.jsp">Voltar</a>
</form>

<%
}catch (Exception e) {
	
}
%>